<template>
  <!-- 过度动画 -->
  <section class="loader_ly" v-show="variable.lyjzdh.value">
    <div class="slider_ly" style="--i: 0"></div>
    <div class="slider_ly" style="--i: 1"></div>
    <div class="slider_ly" style="--i: 2"></div>
    <div class="slider_ly" style="--i: 3"></div>
  </section>

  <router-view />
</template>

<script setup>
  import variable from './js/variable';
  import './js/click-colorful';
  const route = useRoute();

  // 购买者请不要将此信息删掉，违者将不再获得更新版本！
  // console.log(
  //   "%c🌻 技术：SpringBoot3+Vue3 | 作者：阿杜 | 博客：https://adu88.top 🌻",
  //   "color:#fff; background: linear-gradient(270deg, #18d7d3, #68b7dd, #8695e6, #986fee); padding: 8px 15px; border-radius: 8px"
  // );

  watch(
    () => route.name,
    (newV, oldV) => {
      if (newV != 'Zhongxin') {
        //页面打开后至于最顶部
        window.scrollTo({
          top: 0,
        });
      }
    },
  );

  //禁用f12
  if (window.location.hostname != 'localhost') {
    document.addEventListener('DOMContentLoaded', function () {
      window.addEventListener('keydown', function (e) {
        if (e.key === 'F12' || (e.ctrlKey && e.shiftKey && e.keyCode === 73)) {
          //禁用F12
          e.preventDefault();
        }
      });
    });
  }

  // 定义一个方法来阻止右键菜单
  const preventContextMenu = (event) => event.preventDefault();
  onMounted(() => {
    // 组件挂载时添加事件监听器
    document.addEventListener('contextmenu', preventContextMenu);
  });
  onUnmounted(() => {
    // 组件卸载前移除事件监听器
    document.removeEventListener('contextmenu', preventContextMenu);
  });
</script>
